package com.example.license.service;

import com.example.license.client.Client;
import com.example.license.client.OrgFeignClient;
import com.example.model.Organization;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service
public class OrganizationService {
    @Autowired
    @Qualifier("orgDiscoveryClient")
    private Client orgDiscoveryClient;

    @Autowired
    @Qualifier("orgRestTemplateClient")
    private Client orgRestTemplateClient;

    @Autowired
    private OrgFeignClient orgFeignClient;

    public Organization getOrganizationById(String clientType, int id){
        if (clientType.equals("discoveryClient")){
            return orgDiscoveryClient.getOrganization(id);
        }else if (clientType.equals("restTemplate")){
            return orgRestTemplateClient.getOrganization(id);
        }else if (clientType.equals("feign")){
            return orgFeignClient.getOrganization(id);
        }
        return null;
    }
}
